package cn.com.dashihui.pay.SQ;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import com.jfinal.kit.PropKit;

import cn.com.dashihui.pay.SQ.Kit.MD5;
import cn.com.dashihui.pay.SQ.Kit.MD5Utils;
import cn.com.dashihui.pay.SQ.Kit.ParamUtils;

public class SQpay {

	//退款查询
	public static Map<String,String> queryRefund(Map dataMap) throws Exception {
	// TODO Auto-generated method stub
		Map reqMap = new HashMap();
		reqMap.put("merchantno", ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("refundNo", ParamUtils.toString(dataMap.get("merOrderNo")));
		MD5 md5 = new MD5();
		String signTxt = MD5Utils.getMd5Str(reqMap)
				+ (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();

		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());
		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://scan.95epay.cn/merRefundQuery.action");
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merchantno", ParamUtils.toString(PropKit.get("SQpay.merNo"))));
        formparams.add(new BasicNameValuePair("refundNo", ParamUtils.toString(reqMap.get("refundNo"))));
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        return sendPost(httpclient, httppost, formparams);
	}
	//退款申请
	public static Map<String,String> refundApp(Map dataMap) throws Exception {
		// TODO Auto-generated method stub
		Map reqMap = new HashMap();
		reqMap.put("merchantno", ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("merchantOrderNo", ParamUtils.toString(dataMap.get("merOrderNo")));
		reqMap.put("orderNo", ParamUtils.toString(dataMap.get("Orderno")));
		reqMap.put("amount", ParamUtils.toString(dataMap.get("payAmount")));
		MD5 md5 = new MD5();
		String signTxt = MD5Utils.getMd5Str(reqMap)
				+ (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();
		System.out.println(signTxt);
		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());
		reqMap.put("refundReason", "测试");
		reqMap.put("tradeDate", ParamUtils.getFormatDate(new Date(), ParamUtils.getDate.DATE_YYYYMMDD));
		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://scan.95epay.cn/merApplyRefund.action");
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merchantno", ParamUtils.toString(PropKit.get("SQpay.merNo"))));
        formparams.add(new BasicNameValuePair("merchantOrderNo", ParamUtils.toString(reqMap.get("merchantOrderNo"))));
        formparams.add(new BasicNameValuePair("orderNo", ParamUtils.toString(reqMap.get("orderNo"))));
        formparams.add(new BasicNameValuePair("amount", ParamUtils.toString(reqMap.get("amount"))));
        formparams.add(new BasicNameValuePair("refundReason", ParamUtils.toString(reqMap.get("refundReason"))));
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        formparams.add(new BasicNameValuePair("tradeDate", ParamUtils.toString(reqMap.get("tradeDate"))));
        return sendPost(httpclient, httppost, formparams);
	}
	//交易结果查询
	public static  Map<String,String>  queryPay(Map dataMap) throws Exception {
		Map reqMap = new HashMap();
		reqMap.put("MerNo", ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("BillNo", ParamUtils.toString(dataMap.get("merOrderNo")));
		MD5 md5 = new MD5();
		String signTxt = MD5Utils.getMd5Str(reqMap)
				+ (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();

		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());
		
		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://query.95epay.cn/searchInterfaceSingleFR.action");
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merNo", ParamUtils.toString(PropKit.get("SQpay.merNo"))));
        formparams.add(new BasicNameValuePair("BillNo", ParamUtils.toString(reqMap.get("BillNo"))));
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        return sendPost1(httpclient, httppost, formparams);
		
}
	//交易接口
	public static Map<String,String> pay(Map dataMap) {
		Map<String, String> reqMap = new HashMap<String, String>();
		reqMap.put("merNo",ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("merOrderNo",ParamUtils.toString(dataMap.get("merOrderNo")));
		reqMap.put("cardNo",ParamUtils.toString(dataMap.get("cardNo")));
		reqMap.put("custName",ParamUtils.toString(dataMap.get("custName")));
		reqMap.put("idType","0");
		reqMap.put("idNo",ParamUtils.toString(dataMap.get("idNo")));
		reqMap.put("phone",ParamUtils.toString(dataMap.get("phoneNo")));
		reqMap.put("payAmount",ParamUtils.toString(dataMap.get("payAmount")));
		reqMap.put("bankCode", ParamUtils.toString(dataMap.get("bankCode")));
		reqMap.put("payType","XYPAY");
		reqMap.put("NotifyURL", ParamUtils.toString(PropKit.get("SQpay.NotifyURL")));
		reqMap.put("purpose","订单支付");
		
		
		reqMap.put("txnTime",ParamUtils.toString(dataMap.get("txnTime")));
		reqMap.put("smsCode",ParamUtils.toString(dataMap.get("smsCode")));
		
		StringBuffer buffer	= new StringBuffer();
		buffer.append("merNo=").append(ParamUtils.toString(PropKit.get("SQpay.merNo"))).append("&");
		buffer.append("merOrderNo=").append(ParamUtils.toString(reqMap.get("merOrderNo"))).append("&");
		buffer.append("custName=").append(ParamUtils.toString(reqMap.get("custName"))).append("&");
		buffer.append("phone=").append(ParamUtils.toString(reqMap.get("phone"))).append("&");
		buffer.append("cardNo=").append(ParamUtils.toString(reqMap.get("cardNo"))).append("&");
		buffer.append("idType=").append("0").append("&");
		buffer.append("idNo=").append(ParamUtils.toString(reqMap.get("idNo"))).append("&");
		buffer.append("payAmount=").append(ParamUtils.toString(reqMap.get("payAmount"))).append("&");
		buffer.append("bankCode=").append(ParamUtils.toString(reqMap.get("bankCode"))).append("&");
		buffer.append("NotifyURL=").append(ParamUtils.toString(PropKit.get("SQpay.NotifyURL"))).append("&");
		
		MD5 md5 = new MD5();
		String signTxt = buffer.toString() + (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();

		reqMap.put("MD5Info",md5.getMD5Info(signTxt).toUpperCase());
		
		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://fastpay.95epay.cn/pay/hfDaikouTrade.action");
        
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merNo", ParamUtils.toString(PropKit.get("SQpay.merNo"))));
        formparams.add(new BasicNameValuePair("custName", ParamUtils.toString(reqMap.get("custName"))));
        formparams.add(new BasicNameValuePair("cardNo",  ParamUtils.toString(reqMap.get("cardNo"))));
        formparams.add(new BasicNameValuePair("phone",  ParamUtils.toString(reqMap.get("phone"))));
        formparams.add(new BasicNameValuePair("idNo", ParamUtils.toString(reqMap.get("idNo"))));
        formparams.add(new BasicNameValuePair("idType", ParamUtils.toString(reqMap.get("idType"))));
        formparams.add(new BasicNameValuePair("payAmount", ParamUtils.toString(reqMap.get("payAmount"))));
        formparams.add(new BasicNameValuePair("merOrderNo", ParamUtils.toString(reqMap.get("merOrderNo"))));
        formparams.add(new BasicNameValuePair("bankCode", ParamUtils.toString(reqMap.get("bankCode"))));
        formparams.add(new BasicNameValuePair("payType", ParamUtils.toString(reqMap.get("payType"))));
        formparams.add(new BasicNameValuePair("NotifyURL", ParamUtils.toString(PropKit.get("SQpay.NotifyURL"))));
        formparams.add(new BasicNameValuePair("txnTime", ParamUtils.toString(reqMap.get("txnTime"))));
        formparams.add(new BasicNameValuePair("smsCode", ParamUtils.toString(reqMap.get("smsCode"))));
        formparams.add(new BasicNameValuePair("purpose", ParamUtils.toString(reqMap.get("purpose"))));
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        return sendPost(httpclient, httppost, formparams);
		
}
	//支付短信
	public static Map<String,String> payMsg(Map dataMap) throws Exception {
		Map<String, String> reqMap = new HashMap<String, String>();
		reqMap.put("custName",ParamUtils.toString(dataMap.get("custName")));
		reqMap.put("cardNo",ParamUtils.toString(dataMap.get("cardNo")));
		reqMap.put("phone",ParamUtils.toString(dataMap.get("phoneNo")));
		reqMap.put("idNo",ParamUtils.toString(dataMap.get("idNo")));
		reqMap.put("idType", "0");
		reqMap.put("payAmount",ParamUtils.toString(dataMap.get("payAmount")));
		reqMap.put("merOrderNo",ParamUtils.toString(dataMap.get("merOrderNo")));

	
		reqMap.put("cardType", "1");
		reqMap.put("transDate",ParamUtils.getFormatDate(new Date(), ParamUtils.getDate.DATE_YYYYMMDD));
		reqMap.put("transTime", ParamUtils.getFormatDate(new Date(), ParamUtils.getDate.DATE_HHMMSS));
		reqMap.put("bankCode",ParamUtils.toString(dataMap.get("bankCode")));
		reqMap.put("payType", "XYPAY");
		reqMap.put("NotifyURL", ParamUtils.toString(PropKit.get("SQpay.NotifyURL")));
		reqMap.put("purpose","");
		
		reqMap.put("year","");
		reqMap.put("month","");
		reqMap.put("CVV2","");
		
		StringBuffer buffer = new StringBuffer();
		buffer.append("merNo=").append(ParamUtils.toString(PropKit.get("SQpay.merNo"))).append("&");
		buffer.append("custName=").append(ParamUtils.toString(reqMap.get("custName"))).append("&");
		buffer.append("phone=").append(ParamUtils.toString(reqMap.get("phone"))).append("&");
		buffer.append("cardNo=").append(ParamUtils.toString(reqMap.get("cardNo"))).append("&");
		buffer.append("idNo=").append(ParamUtils.toString(reqMap.get("idNo"))).append("&");
		buffer.append("idType=").append("0").append("&");
		buffer.append("payAmount=").append(ParamUtils.toString(reqMap.get("payAmount"))).append("&");
		buffer.append("merOrderNo=").append(ParamUtils.toString(reqMap.get("merOrderNo"))).append("&");
		buffer.append("cardType=").append("1").append("&");
		buffer.append("year=").append("").append("&");
		buffer.append("month=").append("").append("&");
		buffer.append("CVV2=").append("").append("&");
		buffer.append("transDate=").append(ParamUtils.toString(reqMap.get("transDate"))).append("&");
		buffer.append("transTime=").append(ParamUtils.toString(reqMap.get("transTime"))).append("&");
		
		MD5 md5 = new MD5();
		String signTxt = buffer.toString() + (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();
		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());
		

		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://fastpay.95epay.cn/pay/realnameAuth.action");
        
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merNo", ParamUtils.toString(PropKit.get("SQpay.merNo"))));
        formparams.add(new BasicNameValuePair("custName", ParamUtils.toString(reqMap.get("custName"))));
        formparams.add(new BasicNameValuePair("cardNo",  ParamUtils.toString(reqMap.get("cardNo"))));
        formparams.add(new BasicNameValuePair("phone",  ParamUtils.toString(reqMap.get("phone"))));
        formparams.add(new BasicNameValuePair("idNo", ParamUtils.toString(reqMap.get("idNo"))));
        formparams.add(new BasicNameValuePair("idType", ParamUtils.toString(reqMap.get("idType"))));
        formparams.add(new BasicNameValuePair("payAmount", ParamUtils.toString(reqMap.get("payAmount"))));
        formparams.add(new BasicNameValuePair("merOrderNo", ParamUtils.toString(reqMap.get("merOrderNo"))));
        formparams.add(new BasicNameValuePair("bankCode", ParamUtils.toString(reqMap.get("bankCode"))));
        formparams.add(new BasicNameValuePair("payType", ParamUtils.toString(reqMap.get("payType"))));
        formparams.add(new BasicNameValuePair("cardType", ParamUtils.toString(reqMap.get("cardType"))));
        formparams.add(new BasicNameValuePair("NotifyURL", ParamUtils.toString(PropKit.get("SQpay.NotifyURL"))));
        formparams.add(new BasicNameValuePair("transDate", ParamUtils.toString(reqMap.get("transDate"))));
        formparams.add(new BasicNameValuePair("transTime", ParamUtils.toString(reqMap.get("transTime"))));
        formparams.add(new BasicNameValuePair("purpose", ParamUtils.toString(reqMap.get("purpose"))));
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        return sendPost(httpclient, httppost, formparams);
}
	
	public static  Map<String,String>  sendPost(CloseableHttpClient httpclient, HttpPost httppost, List<NameValuePair> formparams) {
		UrlEncodedFormEntity uefEntity;  
		RequestConfig requestConfig = RequestConfig.custom()
        .setSocketTimeout(60000).setConnectTimeout(9000).build();
		httppost.setConfig(requestConfig);
		Map map = null;
        try {  
        	System.out.println("请求"+formparams.toString());
            uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");  
            httppost.setEntity(uefEntity);  
            System.out.println("executing request " + httppost.getURI());  
            CloseableHttpResponse response = httpclient.execute(httppost);  
            try {
            	  HttpEntity entity = response.getEntity();
                  if (entity != null) {
                  	 String str = EntityUtils.toString(entity, "UTF-8");
                      System.out.println("--------------------------------------");
                      System.out.println("Response content: " + str);
                      System.out.println("--------------------------------------");
                      String[] strs = str.substring(2, str.length()-2).split("\",\"");
                      map = new HashMap<String,String>();
              		for(String s : strs){
              			String[] s1 = s.split("\":\"");
              			map.put(s1[0], s1[1]);
              		}
                  }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源 
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return map;
	}
	public static  Map<String,String>  sendPost1(CloseableHttpClient httpclient, HttpPost httppost, List<NameValuePair> formparams) {
		UrlEncodedFormEntity uefEntity;  
		RequestConfig requestConfig = RequestConfig.custom()
        .setSocketTimeout(60000).setConnectTimeout(9000).build();
		httppost.setConfig(requestConfig);
		Map<String,String> map = null;
        try {  
        	System.out.println("请求"+formparams.toString());
            uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");  
            httppost.setEntity(uefEntity);  
            System.out.println("executing request " + httppost.getURI());  
            CloseableHttpResponse response = httpclient.execute(httppost);  
            try {
            	  HttpEntity entity = response.getEntity();
                  if (entity != null) {
                  	 String str1 = EntityUtils.toString(entity, "UTF-8");
                      System.out.println("--------------------------------------");
                      System.out.println("Response content: " + str1);
                      System.out.println("--------------------------------------");
                      String strs = str1.substring(str1.indexOf("State")+7, str1.indexOf("State")+8);
                      String strs1 = str1.substring(str1.indexOf("message")+9, str1.indexOf("message")+13);
                      System.out.println("--------------------------------------"+strs);
                      System.out.println("--------------------------------------"+strs1);
                      map = new HashMap<String,String>();
                      map.put("State", strs);
                      map.put("message", strs1);
                  }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源 
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        
        return map;
	}
	//解约
	public static Map<String,String> breakContract(Map<String,String> dataMap) throws Exception {
		// TODO Auto-generated method stub
		Map<String, String> reqMap = new HashMap<String, String>();
		reqMap.put("merNo", ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("custName", ParamUtils.toString(dataMap.get("custName")));
		reqMap.put("phoneNo", ParamUtils.toString(dataMap.get("phoneNo")));
		reqMap.put("cardNo", ParamUtils.toString(dataMap.get("cardNo")));
		reqMap.put("idNo", ParamUtils.toString(dataMap.get("idNo")));
		reqMap.put("reqMsgId", ParamUtils.getFormatDate(new Date(), ParamUtils.getDate.DATE_YYYYMMDD) + ParamUtils.getRandom(6));
		reqMap.put("payType", "XYPAY");
		MD5 md5 = new MD5();
		String signTxt = MD5Utils.getMd5Str(reqMap)
				+ (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();
		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());

		System.out.println("signTxt"+ParamUtils.toString(reqMap.get("MD5Info")));
		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://fastpay.95epay.cn/pay/breakBindCard.action");
        
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("cardNo",  ParamUtils.toString(reqMap.get("cardNo"))));
        formparams.add(new BasicNameValuePair("custName", ParamUtils.toString(reqMap.get("custName"))));
        formparams.add(new BasicNameValuePair("idNo", ParamUtils.toString(reqMap.get("idNo"))));
        formparams.add(new BasicNameValuePair("merNo", ParamUtils.toString(reqMap.get("merNo"))));
        formparams.add(new BasicNameValuePair("payType", ParamUtils.toString(reqMap.get("payType"))));
        formparams.add(new BasicNameValuePair("phoneNo", ParamUtils.toString(reqMap.get("phoneNo"))));
        formparams.add(new BasicNameValuePair("reqMsgId", ParamUtils.toString(reqMap.get("reqMsgId"))));  
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        return sendPost(httpclient, httppost, formparams);
	}
	//签约查询
	public static Map<String,String> querySignResult(Map<String,String> dataMap) throws Exception{
		
		Map<String, String> reqMap = new HashMap<String, String>();
		reqMap.put("merNo", ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("custName", ParamUtils.toString(dataMap.get("custName")));
		reqMap.put("phoneNo", ParamUtils.toString(dataMap.get("phoneNo")));
		reqMap.put("cardNo", ParamUtils.toString(dataMap.get("cardNo")));
		reqMap.put("idNo", ParamUtils.toString(dataMap.get("idNo")));
		reqMap.put("payType", "XYPAY");

		MD5 md5 = new MD5();
		String signTxt = MD5Utils.getMd5Str(reqMap)
				+ (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();

		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());
		reqMap.put("payAmount", ParamUtils.toString(dataMap.get("payAmount")));

		
		// 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://fastpay.95epay.cn/pay/querySignResult.action");
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merNo", reqMap.get("merNo")));
        formparams.add(new BasicNameValuePair("custName", reqMap.get("custName")));
        formparams.add(new BasicNameValuePair("phoneNo", reqMap.get("phoneNo")));
        formparams.add(new BasicNameValuePair("cardNo", reqMap.get("cardNo")));
        formparams.add(new BasicNameValuePair("idNo", reqMap.get("idNo")));
        formparams.add(new BasicNameValuePair("MD5Info", reqMap.get("MD5Info")));
        formparams.add(new BasicNameValuePair("payAmount", reqMap.get("payAmount")));  
        formparams.add(new BasicNameValuePair("payType", reqMap.get("payType")));
        
        return sendPost(httpclient, httppost, formparams);
	}
	//签约/认证      custType 02签约  01认证
	public static Map<String,String> Contract(Map<String,String> dataMap) throws Exception {
		
		Map<String, String> reqMap = new HashMap<String, String>();
		reqMap.put("merNo", ParamUtils.toString(PropKit.get("SQpay.merNo")));
		reqMap.put("custName", ParamUtils.toString(dataMap.get("custName")));
		reqMap.put("phoneNo", ParamUtils.toString(dataMap.get("phoneNo")));
		reqMap.put("cardNo", ParamUtils.toString(dataMap.get("cardNo")));

		reqMap.put("bankCode", ParamUtils.toString(dataMap.get("bankCode")));
		reqMap.put("idNo", ParamUtils.toString(dataMap.get("idNo")));
		reqMap.put("idType", "0");
		reqMap.put("reqMsgId", ParamUtils.getFormatDate(new Date(), ParamUtils.getDate.DATE_YYYYMMDD) + ParamUtils.getRandom(6));
		reqMap.put("cardType", "1");
		reqMap.put("authMsg", "075216");
		reqMap.put("custType", ParamUtils.toString(dataMap.get("custType")));
		reqMap.put("payType", "XYPAY");

		MD5 md5 = new MD5();
		String signTxt = MD5Utils.getMd5Str(reqMap)
				+ (md5.getMD5Info(ParamUtils.toString(PropKit.get("SQpay.MD5Key")))).toUpperCase();
		reqMap.put("MD5Info", md5.getMD5Info(signTxt).toUpperCase());

		
        // 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost("https://fastpay.95epay.cn/pay/identifyAuthAndSign.action");
        // 创建参数队列    
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("merNo", ParamUtils.toString(reqMap.get("merNo"))));
        formparams.add(new BasicNameValuePair("custName", ParamUtils.toString(reqMap.get("custName"))));
        formparams.add(new BasicNameValuePair("phoneNo", ParamUtils.toString(reqMap.get("phoneNo"))));
        formparams.add(new BasicNameValuePair("cardNo", ParamUtils.toString(reqMap.get("cardNo"))));
        formparams.add(new BasicNameValuePair("bankCode", ParamUtils.toString(reqMap.get("bankCode"))));
        formparams.add(new BasicNameValuePair("idNo", ParamUtils.toString(reqMap.get("idNo"))));
        formparams.add(new BasicNameValuePair("idType", ParamUtils.toString(reqMap.get("idType"))));  
        formparams.add(new BasicNameValuePair("reqMsgId", ParamUtils.toString(reqMap.get("reqMsgId"))));
        formparams.add(new BasicNameValuePair("cardType", ParamUtils.toString(reqMap.get("cardType"))));  
        formparams.add(new BasicNameValuePair("authMsg", ParamUtils.toString(reqMap.get("authMsg"))));
        formparams.add(new BasicNameValuePair("custType", ParamUtils.toString(reqMap.get("custType"))));  
        formparams.add(new BasicNameValuePair("payType", ParamUtils.toString(reqMap.get("payType"))));
        formparams.add(new BasicNameValuePair("MD5Info", ParamUtils.toString(reqMap.get("MD5Info"))));
        
        return sendPost(httpclient, httppost, formparams);
	}
	
}
